// 导入用户集合
const { User } = require('../../../model/user');
const { decodeToken } = require('../../../middleGuard/jwt')

module.exports = (req, res) => {
  const users = User.updateOne({_id: decodeToken(req.headers.authorization).userId}, {...req.body}, (err, row) => {
    console.log('err', err)
    console.log('row', row)
    if(!err) {
      res.json({
        message: '更新成功!',
        data: {
            ...req.body
        }
      })
    } else {
      res.status(403)
      res.json({
        log: err,
        message: '更新失败！'
      })
    }
  })
}